package com.xbao.controller;

import com.xbao.core.http.CommRequest;
import com.xbao.core.http.CommResult;
import com.xbao.model.GuideDoc;
import com.xbao.model.req.SubjectReq;
import com.xbao.service.GuideDocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/*@Api(value = "/guide", tags = "guide")
@RequestMapping(value = "guide")
@Controller
@EnableAutoConfiguration*/
public class GuideDocController extends BaseController {
    @Resource
    private GuideDocService docService;
    @ApiOperation(value = "addDoc", notes = "addDoc")
    @RequestMapping(value = "/add",method = RequestMethod.POST)
    @ResponseBody
    public Object add(@RequestBody CommRequest<GuideDoc> docCommRequest) {
        docService.addGuideDoc(docCommRequest.getData());
        return result();
    }
    @ApiOperation(value = "update", notes = "update")
    @RequestMapping(value = "/update",method = RequestMethod.POST)
    @ResponseBody
    public Object update(@RequestBody CommRequest<GuideDoc> guideDocCommRequest) {
        docService.updateGuideDoc(guideDocCommRequest.getData());

        return result();
    }

    @ApiOperation(value = "delete", notes = "delete")
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    @ResponseBody
    public Object delete(@RequestBody CommRequest<GuideDoc> commRequest) {
    docService.deleteGuideDoc(commRequest.getData().getId());
        return result();
    }
    @ApiOperation(value = "list", notes = "list")
    @RequestMapping(value = "/list",method = RequestMethod.POST)
    @ResponseBody
    public Object list(@RequestBody CommRequest<GuideDoc> guideDocCommRequest) {
        List<GuideDoc> docs= docService.listGuideDocs(guideDocCommRequest.getData());
        return new CommResult<>(docs);
    }

}
